import { h } from 'vue'

export default {
    name: 'remote-script',
    props: {
        src: {
            type: String,
            required: true
        }
    },
    render() {
        let self = this;
        return h('script', {
            type: 'text/javascript',
            src: this.src,
            onload(event) {
                self.$emit('loadData', event);
            },
            onerror(event) {
                self.$emit('error', event);
            },
            onreadystatechange: function (event) {
                if (this.readyState == 'complete') {
                    self.$emit('load', event);
                }
            }
        });
    }
}
